# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
# RUN: llc -mtriple=thumbv8.1m.main-none-eabi -mattr=+mve -run-pass arm-mve-vpt %s -o - | FileCheck %s

--- |

  define arm_aapcs_vfpcc <4 x i32> @vpnot(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c) {
  entry:
    %0 = icmp slt <4 x i32> %a, zeroinitializer
    %c2 = icmp sgt <4 x i32> %b, zeroinitializer
    %c3 = icmp eq <4 x i32> %c, zeroinitializer
    %o1 = and <4 x i1> %0, %c2
    %o2 = xor <4 x i1> %o1, <i1 true, i1 true, i1 true, i1 true>
    %o = and <4 x i1> %c3, %o2
    %s = select <4 x i1> %o, <4 x i32> %a, <4 x i32> %b
    ret <4 x i32> %s
  }

  define arm_aapcs_vfpcc <4 x i32> @vpnot_end(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c) {
  entry:
    %0 = icmp slt <4 x i32> %a, zeroinitializer
    %c2 = icmp sgt <4 x i32> %b, zeroinitializer
    %c3 = icmp eq <4 x i32> %c, zeroinitializer
    %o1 = and <4 x i1> %0, %c2
    %o2 = xor <4 x i1> %o1, <i1 true, i1 true, i1 true, i1 true>
    br label %bb2
  bb2:
    %o = and <4 x i1> %c3, %o2
    %s = select <4 x i1> %o, <4 x i32> %a, <4 x i32> %b
    ret <4 x i32> %s
  }

  define arm_aapcs_vfpcc <4 x i32> @vpnot_two(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c) {
  entry:
    unreachable
  }
  define arm_aapcs_vfpcc <4 x i32> @vpnot_lots(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c) {
  entry:
    unreachable
  }
  define arm_aapcs_vfpcc <4 x i32> @vpnot_first(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c) {
  entry:
    unreachable
  }
  define arm_aapcs_vfpcc <4 x i32> @vpnot_many(<4 x i32> %a, <4 x i32> %b, <4 x i32> %c) {
  entry:
    unreachable
  }

...
---
name:            vpnot
alignment:       4
tracksRegLiveness: true
liveins:
  - { reg: '$q0', virtual-reg: '' }
  - { reg: '$q1', virtual-reg: '' }
  - { reg: '$q2', virtual-reg: '' }
body:             |
  bb.0.entry:
    liveins: $q0, $q1, $q2

    ; CHECK-LABEL: name: vpnot
    ; CHECK: liveins: $q0, $q1, $q2
    ; CHECK: BUNDLE implicit-def $vpr, implicit $q0, implicit $zr, implicit $q1, implicit killed $q2 {
    ; CHECK:   MVE_VPTv4s32r 12, renamable $q0, $zr, 11, implicit-def $vpr
    ; CHECK:   renamable $vpr = MVE_VCMPs32r renamable $q1, $zr, 12, 1, internal killed renamable $vpr, $noreg
    ; CHECK:   renamable $vpr = MVE_VCMPi32r killed renamable $q2, $zr, 0, 2, internal killed renamable $vpr, $noreg
    ; CHECK: }
    ; CHECK: renamable $q0 = MVE_VPSEL killed renamable $q0, killed renamable $q1, 0, killed renamable $vpr, $noreg
    ; CHECK: tBX_RET 14 /* CC::al */, $noreg, implicit $q0
    renamable $vpr = MVE_VCMPs32r renamable $q0, $zr, 11, 0, $noreg, $noreg
    renamable $vpr = MVE_VCMPs32r renamable $q1, $zr, 12, 1, killed renamable $vpr, $noreg
    renamable $vpr = MVE_VPNOT killed renamable $vpr, 0, $noreg, $noreg
    renamable $vpr = MVE_VCMPi32r killed renamable $q2, $zr, 0, 1, killed renamable $vpr, $noreg
    renamable $q0 = MVE_VPSEL killed renamable $q0, killed renamable $q1, 0, killed renamable $vpr, $noreg
    tBX_RET 14, $noreg, implicit $q0

...
---
name:            vpnot_end
alignment:       4
tracksRegLiveness: true
liveins:
  - { reg: '$q0', virtual-reg: '' }
  - { reg: '$q1', virtual-reg: '' }
  - { reg: '$q2', virtual-reg: '' }
body:             |
  ; CHECK-LABEL: name: vpnot_end
  ; CHECK: bb.0.entry:
  ; CHECK:   successors: %bb.1(0x80000000)
  ; CHECK:   liveins: $q0, $q1, $q2
  ; CHECK:   BUNDLE implicit-def $vpr, implicit $q0, implicit $zr, implicit $q1 {
  ; CHECK:     MVE_VPTv4s32r 8, renamable $q0, $zr, 11, implicit-def $vpr
  ; CHECK:     renamable $vpr = MVE_VCMPs32r renamable $q1, $zr, 12, 1, internal killed renamable $vpr, $noreg
  ; CHECK:   }
  ; CHECK:   renamable $vpr = MVE_VPNOT killed renamable $vpr, 0, $noreg, $noreg
  ; CHECK: bb.1.bb2:
  ; CHECK:   liveins: $q0, $q1, $q2, $vpr
  ; CHECK:   BUNDLE implicit-def $vpr, implicit killed $vpr, implicit killed $q2, implicit $zr {
  ; CHECK:     MVE_VPST 8, implicit $vpr
  ; CHECK:     renamable $vpr = MVE_VCMPi32r killed renamable $q2, $zr, 0, 1, killed renamable $vpr, $noreg
  ; CHECK:   }
  ; CHECK:   renamable $q0 = MVE_VPSEL killed renamable $q0, killed renamable $q1, 0, killed renamable $vpr, $noreg
  ; CHECK:   tBX_RET 14 /* CC::al */, $noreg, implicit $q0
  bb.0.entry:
    liveins: $q0, $q1, $q2

    renamable $vpr = MVE_VCMPs32r renamable $q0, $zr, 11, 0, $noreg, $noreg
    renamable $vpr = MVE_VCMPs32r renamable $q1, $zr, 12, 1, killed renamable $vpr, $noreg
    renamable $vpr = MVE_VPNOT killed renamable $vpr, 0, $noreg, $noreg

  bb.1.bb2:
    liveins: $q0, $q1, $q2, $vpr

    renamable $vpr = MVE_VCMPi32r killed renamable $q2, $zr, 0, 1, killed renamable $vpr, $noreg
    renamable $q0 = MVE_VPSEL killed renamable $q0, killed renamable $q1, 0, killed renamable $vpr, $noreg
    tBX_RET 14, $noreg, implicit $q0

...
---
name:            vpnot_two
alignment:       4
tracksRegLiveness: true
liveins:
  - { reg: '$q0', virtual-reg: '' }
  - { reg: '$q1', virtual-reg: '' }
  - { reg: '$q2', virtual-reg: '' }
body:             |
  bb.0.entry:
    liveins: $q0, $q1, $q2

    ; CHECK-LABEL: name: vpnot_two
    ; CHECK: liveins: $q0, $q1, $q2
    ; CHECK: BUNDLE implicit-def $vpr, implicit $q0, implicit $zr, implicit $q1 {
    ; CHECK:   MVE_VPTv4s32r 8, renamable $q0, $zr, 11, implicit-def $vpr
    ; CHECK:   renamable $vpr = MVE_VCMPs32r renamable $q1, $zr, 12, 1, internal killed renamable $vpr, $noreg
    ; CHECK: }
    ; CHECK: renamable $vpr = MVE_VPNOT killed renamable $vpr, 0, $noreg, $noreg
    ; CHECK: renamable $vpr = MVE_VPNOT killed renamable $vpr, 0, $noreg, $noreg
    ; CHECK: BUNDLE implicit-def $vpr, implicit killed $vpr, implicit killed $q2, implicit $zr {
    ; CHECK:   MVE_VPST 8, implicit $vpr
    ; CHECK:   renamable $vpr = MVE_VCMPi32r killed renamable $q2, $zr, 0, 1, killed renamable $vpr, $noreg
    ; CHECK: }
    ; CHECK: renamable $q0 = MVE_VPSEL killed renamable $q0, killed renamable $q1, 0, killed renamable $vpr, $noreg
    ; CHECK: tBX_RET 14 /* CC::al */, $noreg, implicit $q0
    renamable $vpr = MVE_VCMPs32r renamable $q0, $zr, 11, 0, $noreg, $noreg
    renamable $vpr = MVE_VCMPs32r renamable $q1, $zr, 12, 1, killed renamable $vpr, $noreg
    renamable $vpr = MVE_VPNOT killed renamable $vpr, 0, $noreg, $noreg
    renamable $vpr = MVE_VPNOT killed renamable $vpr, 0, $noreg, $noreg
    renamable $vpr = MVE_VCMPi32r killed renamable $q2, $zr, 0, 1, killed renamable $vpr, $noreg
    renamable $q0 = MVE_VPSEL killed renamable $q0, killed renamable $q1, 0, killed renamable $vpr, $noreg
    tBX_RET 14, $noreg, implicit $q0

...
---
name:            vpnot_lots
alignment:       4
tracksRegLiveness: true
liveins:
  - { reg: '$q0', virtual-reg: '' }
  - { reg: '$q1', virtual-reg: '' }
  - { reg: '$q2', virtual-reg: '' }
body:             |
  bb.0.entry:
    liveins: $q0, $q1, $q2

    ; CHECK-LABEL: name: vpnot_lots
    ; CHECK: liveins: $q0, $q1, $q2
    ; CHECK: BUNDLE implicit-def $vpr, implicit $q0, implicit $zr, implicit $q1 {
    ; CHECK:   MVE_VPTv4s32r 8, renamable $q0, $zr, 11, implicit-def $vpr
    ; CHECK:   renamable $vpr = MVE_VCMPs32r renamable $q1, $zr, 12, 1, internal killed renamable $vpr, $noreg
    ; CHECK: }
    ; CHECK: renamable $vpr = MVE_VPNOT killed renamable $vpr, 0, $noreg, $noreg
    ; CHECK: renamable $vpr = MVE_VPNOT killed renamable $vpr, 0, $noreg, $noreg
    ; CHECK: renamable $vpr = MVE_VPNOT killed renamable $vpr, 0, $noreg, $noreg
    ; CHECK: renamable $vpr = MVE_VPNOT killed renamable $vpr, 0, $noreg, $noreg
    ; CHECK: renamable $vpr = MVE_VPNOT killed renamable $vpr, 0, $noreg, $noreg
    ; CHECK: BUNDLE implicit-def $vpr, implicit killed $vpr, implicit killed $q2, implicit $zr {
    ; CHECK:   MVE_VPST 8, implicit $vpr
    ; CHECK:   renamable $vpr = MVE_VCMPi32r killed renamable $q2, $zr, 0, 1, killed renamable $vpr, $noreg
    ; CHECK: }
    ; CHECK: renamable $q0 = MVE_VPSEL killed renamable $q0, killed renamable $q1, 0, killed renamable $vpr, $noreg
    ; CHECK: tBX_RET 14 /* CC::al */, $noreg, implicit $q0
    renamable $vpr = MVE_VCMPs32r renamable $q0, $zr, 11, 0, $noreg, $noreg
    renamable $vpr = MVE_VCMPs32r renamable $q1, $zr, 12, 1, killed renamable $vpr, $noreg
    renamable $vpr = MVE_VPNOT killed renamable $vpr, 0, $noreg, $noreg
    renamable $vpr = MVE_VPNOT killed renamable $vpr, 0, $noreg, $noreg
    renamable $vpr = MVE_VPNOT killed renamable $vpr, 0, $noreg, $noreg
    renamable $vpr = MVE_VPNOT killed renamable $vpr, 0, $noreg, $noreg
    renamable $vpr = MVE_VPNOT killed renamable $vpr, 0, $noreg, $noreg
    renamable $vpr = MVE_VCMPi32r killed renamable $q2, $zr, 0, 1, killed renamable $vpr, $noreg
    renamable $q0 = MVE_VPSEL killed renamable $q0, killed renamable $q1, 0, killed renamable $vpr, $noreg
    tBX_RET 14, $noreg, implicit $q0

...
---
name:            vpnot_first
alignment:       4
tracksRegLiveness: true
liveins:
  - { reg: '$q0', virtual-reg: '' }
  - { reg: '$q1', virtual-reg: '' }
  - { reg: '$q2', virtual-reg: '' }
body:             |
  bb.0.entry:
    liveins: $q0, $q1, $q2

    ; CHECK-LABEL: name: vpnot_first
    ; CHECK: liveins: $q0, $q1, $q2
    ; CHECK: renamable $vpr = MVE_VCMPs32r renamable $q0, $zr, 11, 0, $noreg, $noreg
    ; CHECK: renamable $vpr = MVE_VPNOT killed renamable $vpr, 0, $noreg, $noreg
    ; CHECK: BUNDLE implicit-def $vpr, implicit killed $vpr, implicit $q1, implicit $zr, implicit killed $q2 {
    ; CHECK:   MVE_VPST 4, implicit $vpr
    ; CHECK:   renamable $vpr = MVE_VCMPs32r renamable $q1, $zr, 12, 1, killed renamable $vpr, $noreg
    ; CHECK:   renamable $vpr = MVE_VCMPi32r killed renamable $q2, $zr, 0, 1, internal killed renamable $vpr, $noreg
    ; CHECK: }
    ; CHECK: renamable $q0 = MVE_VPSEL killed renamable $q0, killed renamable $q1, 0, killed renamable $vpr, $noreg
    ; CHECK: tBX_RET 14 /* CC::al */, $noreg, implicit $q0
    renamable $vpr = MVE_VCMPs32r renamable $q0, $zr, 11, 0, $noreg, $noreg
    renamable $vpr = MVE_VPNOT killed renamable $vpr, 0, $noreg, $noreg
    renamable $vpr = MVE_VCMPs32r renamable $q1, $zr, 12, 1, killed renamable $vpr, $noreg
    renamable $vpr = MVE_VCMPi32r killed renamable $q2, $zr, 0, 1, killed renamable $vpr, $noreg
    renamable $q0 = MVE_VPSEL killed renamable $q0, killed renamable $q1, 0, killed renamable $vpr, $noreg
    tBX_RET 14, $noreg, implicit $q0

...
---
name:            vpnot_many
alignment:       4
tracksRegLiveness: true
liveins:
  - { reg: '$q0', virtual-reg: '' }
  - { reg: '$q1', virtual-reg: '' }
  - { reg: '$q2', virtual-reg: '' }
body:             |
  bb.0.entry:
    liveins: $q0, $q1, $q2

    ; CHECK-LABEL: name: vpnot_many
    ; CHECK: liveins: $q0, $q1, $q2
    ; CHECK: renamable $vpr = MVE_VCMPs32r renamable $q0, $zr, 11, 0, $noreg, $noreg
    ; CHECK: renamable $vpr = MVE_VPNOT killed renamable $vpr, 0, $noreg, $noreg
    ; CHECK: BUNDLE implicit-def $vpr, implicit killed $vpr, implicit $q1, implicit $zr, implicit killed $q2 {
    ; CHECK:   MVE_VPST 12, implicit $vpr
    ; CHECK:   renamable $vpr = MVE_VCMPs32r renamable $q1, $zr, 12, 1, killed renamable $vpr, $noreg
    ; CHECK:   renamable $vpr = MVE_VCMPi32r killed renamable $q2, $zr, 0, 2, internal killed renamable $vpr, $noreg
    ; CHECK: }
    ; CHECK: renamable $vpr = MVE_VPNOT killed renamable $vpr, 0, $noreg, $noreg
    ; CHECK: renamable $q0 = MVE_VPSEL killed renamable $q0, killed renamable $q1, 0, killed renamable $vpr, $noreg
    ; CHECK: tBX_RET 14 /* CC::al */, $noreg, implicit $q0
    renamable $vpr = MVE_VCMPs32r renamable $q0, $zr, 11, 0, $noreg, $noreg
    renamable $vpr = MVE_VPNOT killed renamable $vpr, 0, $noreg, $noreg
    renamable $vpr = MVE_VCMPs32r renamable $q1, $zr, 12, 1, killed renamable $vpr, $noreg
    renamable $vpr = MVE_VPNOT killed renamable $vpr, 0, $noreg, $noreg
    renamable $vpr = MVE_VCMPi32r killed renamable $q2, $zr, 0, 1, killed renamable $vpr, $noreg
    renamable $vpr = MVE_VPNOT killed renamable $vpr, 0, $noreg, $noreg
    renamable $q0 = MVE_VPSEL killed renamable $q0, killed renamable $q1, 0, killed renamable $vpr, $noreg
    tBX_RET 14, $noreg, implicit $q0

...
